import plotly.offline as pyo
from plotly.graph_objs import *
import chart_studio.plotly as py
import pandas as pd
from pandas import DataFrame
pyo.offline.init_notebook_mode()
baserate = pd.read_csv(r"../Data/BoEBaseRate.csv")
baserate.drop_duplicates(subset="VALUE", inplace=True)
baserate = baserate.tail(10)
baserate
| Unnamed: 0 | VALUE | DATE | |
|---|---|---|---|
| 6767 | 6767 | 4.50 | 2001-10-04 |
| 6792 | 6792 | 4.00 | 2001-11-08 |
| 7105 | 7105 | 3.75 | 2003-02-06 |
| 7211 | 7211 | 3.50 | 2003-07-10 |
| 7419 | 7419 | 4.25 | 2004-05-06 |
| 8560 | 8560 | 3.00 | 2008-11-06 |
| 8580 | 8580 | 2.00 | 2008-12-04 |
| 8602 | 8602 | 1.50 | 2009-01-08 |
| 8622 | 8622 | 1.00 | 2009-02-05 |
| 8642 | 8642 | 0.50 | 2009-03-05 |
baseRateTrace = {'type' : 'scatter',
'x' : baserate['DATE'],
'y' : baserate['VALUE'],
'mode' : 'lines+markers',
'line' : {'shape' : 'hv'},
'name' : 'BoE Base Rate'}
layout = {'title' : 'Bank of England Base Rate, 2001-2009',
'xaxis' : {'title' : 'Date'},
'yaxis' : {'title' : 'Base Rate (%)'}}
data = Data([baseRateTrace])
fig = Figure(data = data, layout = layout)
pyo.iplot(fig)
def updateLine(val):
baseRateTrace['line'].update({'shape' : val})
data = Data([baseRateTrace])
fig = Figure(data=data, layout=layout)
pyo.iplot(fig)
updateLine('linear')
updateLine('vh')
updateLine('hvh')
updateLine('vhv')